package com.example.day1201_wlan.slice;

import com.example.day1201_wlan.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.window.dialog.ToastDialog;
import ohos.wifi.WifiDevice;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);


        findComponentById(ResourceTable.Id_function_button)
                .setClickedListener(component -> present(new BasisFunction(), new Intent()));
        findComponentById(ResourceTable.Id_hot_trust_config_button)
                .setClickedListener(component -> present(new HotConfig(),new Intent()));
        findComponentById(ResourceTable.Id_message_button)
                .setClickedListener(component -> present(new Message(),new Intent()));

        WifiDevice wifiDevice = WifiDevice.getInstance(this);
        boolean isWifiActive = wifiDevice.isWifiActive();
        new ToastDialog(getContext()).setText(isWifiActive ? "WIFI已打开" : "WIFI已关闭").show();

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
